package f_genericity;

import java.util.ArrayList;

/**
 * @author Cheng-02
 * @version V1.0
 * @Package f_genericity
 * @date 2024/4/8 下午2:44
 */
public class Test03 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        ListUtils.addAll(list, "a", "b", "c", "d");
        System.out.println(list);
        ArrayList<Integer> list1 = new ArrayList<>();
        ListUtils.addAll(list1, 1, 2, 3, 4);
        System.out.println(list1);
    }
}

class ListUtils<E> {
    //定义一个静态方法，添加多个元素
    public static <E> void addAll(ArrayList<E> list, E... e) {
        for (E e1 : e) {
            list.add(e1);
        }
    }
}
